package com.zfy.cmsservice.service.impl;

import com.zfy.cmsservice.entity.Courses;
import com.zfy.cmsservice.entity.vo.CoursesVo;
import com.zfy.cmsservice.mapper.CoursesMapper;
import com.zfy.cmsservice.service.CoursesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zfy.commonutils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 课程表 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2023-12-03
 */
@Service
public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> implements CoursesService {

    @Autowired
    CoursesMapper coursesMapper;

    @Override
    public R pageCourses(long page, long size, String name) {
        // 不走mybatis-plus分页插件的处理
        page = (page-1)*size;
        List<CoursesVo> records = coursesMapper.pageCourses(page,size,name);
        int total = coursesMapper.pageCoursesTotal(page,size,name);
        return R.ok().data("total", total).data("content", records);
    }

    @Override
    public List<Courses> findAllTeacher() {
        return coursesMapper.findAllTeacher();
    }

    @Override
    public List<Courses> getElective() {
        return coursesMapper.getElective();
    }
}
